package com.test.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.test.util.GetDirPathUtil;
import org.springframework.web.bind.annotation.*;
import com.zhuozhengsoft.pageoffice.*;
@RestController
@RequestMapping(value = "/doc")
public class DocumentController {
    //获取doc目录的磁盘路径
    private String dir = GetDirPathUtil.getDirPath() + "static/";

    @RequestMapping(value="/openFile")
    public String openFile(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        poCtrl.setSaveFilePage("saveFile");
        poCtrl.webOpen("/test.doc", OpenModeType.docNormalEdit, "张三");
        return  poCtrl.getHtmlCode("PageOfficeCtrl1");
    }

    @RequestMapping("/saveFile")
    public void saveFile(HttpServletRequest request, HttpServletResponse response) {
        FileSaver fs = new FileSaver(request, response);
        fs.saveToFile(dir + fs.getFileName());
        fs.close();
    }
}

